﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_RptKetQuaHoatDongKinhDoanh : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("Cb_CapNhat")]
        private CheckBox _Cb_CapNhat;
        [AccessedThroughProperty("CboDonVi")]
        private ComboBox _CboDonVi;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("GroupBox1")]
        private GroupBox _GroupBox1;
        [AccessedThroughProperty("Label1")]
        private Label _Label1;
        [AccessedThroughProperty("Label13")]
        private Label _Label13;
        [AccessedThroughProperty("Label2")]
        private Label _Label2;
        [AccessedThroughProperty("TxtDenNgay")]
        private DateTimePicker _TxtDenNgay;
        [AccessedThroughProperty("TxtTuNgay")]
        private DateTimePicker _TxtTuNgay;
        private IContainer components;
        private bool mAllowAdd;
        private bool mAllowDel;
        private bool mAllowEdit;
        private bool mAllowView;
        private DataTable pdata;

        [DebuggerNonUserCode]
        public Frm_RptKetQuaHoatDongKinhDoanh()
        {
            base.Load += new EventHandler(this.Frm_RptKetQuaHoatDongKinhDoanh_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.InitializeComponent();
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            this.TxtDenNgay.Focus();
            this.PrintReport();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_RptKetQuaHoatDongKinhDoanh_Load(object sender, EventArgs e)
        {
            LVYModule.GetUserRight(ref this.mAllowView, ref this.mAllowDel, ref this.mAllowEdit, ref this.mAllowAdd, Conversions.ToString(this.Tag), modGeneral.H_USERNAME);
            if (!this.mAllowView)
            {
                LVYModule.ShowWarning(modGeneral.Tranlated("Bạn kh\x00f4ng c\x00f3 quyền xem, li\x00ean hệ với người quản trị để biết th\x00eam chi tiết.", ""));
                this.Dispose();
            }
            else
            {
                BuildComboModule.BuildCombo(this.CboDonVi, modGeneral.ListDanhMuc.DonVi, true, "", "");
                this.CboDonVi.SelectedValue = modGeneral.H_CLIENT;
                this.TxtTuNgay.Text = "01/" + LVYModule.sRight("00" + Conversions.ToString(DateAndTime.Month(DateAndTime.Today)), 2) + "/" + Conversions.ToString(DateAndTime.Year(DateAndTime.Today));
                this.TxtDenNgay.Text = DateTime.DaysInMonth(Conversions.ToInteger(LVYModule.sRight(this.TxtTuNgay.Text, 4)), Conversions.ToInteger(LVYModule.sMid(this.TxtTuNgay.Text, 4, 2))).ToString() + "/" + LVYModule.sRight(this.TxtTuNgay.Text, 7);
            }
        }

        public DataTable GetData()
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[5];
            string str3 = LVYModule.Date2Char(this.TxtTuNgay.Text);
            string str = LVYModule.Date2Char(this.TxtDenNgay.Text);
            string str2 = ((int) Math.Round((double) (Conversions.ToDouble(LVYModule.sLeft(str3, 4)) - 1.0))).ToString();
            try
            {
                commandParameters[0] = DBHelper.createParameter("@TuNgay", DbType.Int64, ParameterDirection.Input, str3);
                commandParameters[1] = DBHelper.createParameter("@DenNgay", DbType.Int64, ParameterDirection.Input, str);
                commandParameters[2] = DBHelper.createParameter("@NamTruoc", DbType.Int64, ParameterDirection.Input, str2);
                commandParameters[3] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, modGeneral.H_CLIENT);
                commandParameters[4] = DBHelper.createParameter("@pError", DbType.Double, ParameterDirection.Output, 0);
                if (modGeneral.H_PHIENBANQUYETDINH == "QD15")
                {
                    return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_BC_KetQuaSanXuatKinhDoanh_15", commandParameters).Tables[0];
                }
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_BC_KetQuaSanXuatKinhDoanh_48", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public DataTable GetDataPrintCN(string strKhoaDonVi, string strNamThang)
        {
            DataTable table;
            IDataParameter[] commandParameters = new IDataParameter[3];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, strKhoaDonVi);
                commandParameters[1] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, strNamThang);
                commandParameters[2] = DBHelper.createParameter("@Language", DbType.Int64, ParameterDirection.Input, modGeneral.H_LANGUAGE);
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.StoredProcedure, "BC_sp_BangKeKetQuaHoatDongKDCuoiNam", commandParameters).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_RptKetQuaHoatDongKinhDoanh));
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.GroupBox1 = new GroupBox();
            this.Label2 = new Label();
            this.TxtDenNgay = new DateTimePicker();
            this.Label13 = new Label();
            this.TxtTuNgay = new DateTimePicker();
            this.Cb_CapNhat = new CheckBox();
            this.Label1 = new Label();
            this.CboDonVi = new ComboBox();
            this.GroupBox1.SuspendLayout();
            this.SuspendLayout();
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = (Image) manager.GetObject("CmdCancel.Image");
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            Point point = new Point(0x137, 0x89);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            Size size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 0x10;
            this.CmdCancel.Text = "&Tho\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = (Image) manager.GetObject("CmdOK.Image");
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0xe4, 0x89);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4e, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 15;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            this.GroupBox1.BackColor = Color.Transparent;
            this.GroupBox1.Controls.Add(this.Label2);
            this.GroupBox1.Controls.Add(this.TxtDenNgay);
            this.GroupBox1.Controls.Add(this.Label13);
            this.GroupBox1.Controls.Add(this.TxtTuNgay);
            this.GroupBox1.Controls.Add(this.Cb_CapNhat);
            this.GroupBox1.Controls.Add(this.Label1);
            this.GroupBox1.Controls.Add(this.CboDonVi);
            point = new Point(6, 5);
            this.GroupBox1.Location = point;
            this.GroupBox1.Name = "GroupBox1";
            size = new Size(0x180, 0x7e);
            this.GroupBox1.Size = size;
            this.GroupBox1.TabIndex = 14;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "T\x00f9y chọn";
            this.Label2.AutoSize = true;
            this.Label2.BackColor = Color.Transparent;
            point = new Point(0xd5, 0x3a);
            this.Label2.Location = point;
            this.Label2.Name = "Label2";
            size = new Size(0x35, 13);
            this.Label2.Size = size;
            this.Label2.TabIndex = 0x43;
            this.Label2.Text = "Đến ng\x00e0y";
            this.TxtDenNgay.Format = DateTimePickerFormat.Custom;
            point = new Point(0x110, 0x37);
            this.TxtDenNgay.Location = point;
            this.TxtDenNgay.Name = "TxtDenNgay";
            size = new Size(0x55, 20);
            this.TxtDenNgay.Size = size;
            this.TxtDenNgay.TabIndex = 0x42;
            this.Label13.AutoSize = true;
            this.Label13.BackColor = Color.Transparent;
            point = new Point(0x26, 0x39);
            this.Label13.Location = point;
            this.Label13.Name = "Label13";
            size = new Size(0x2e, 13);
            this.Label13.Size = size;
            this.Label13.TabIndex = 0x41;
            this.Label13.Text = "Từ ng\x00e0y";
            this.TxtTuNgay.Format = DateTimePickerFormat.Custom;
            point = new Point(0x74, 0x37);
            this.TxtTuNgay.Location = point;
            this.TxtTuNgay.Name = "TxtTuNgay";
            size = new Size(0x53, 20);
            this.TxtTuNgay.Size = size;
            this.TxtTuNgay.TabIndex = 0x40;
            this.Cb_CapNhat.AutoSize = true;
            point = new Point(0x74, 0x83);
            this.Cb_CapNhat.Location = point;
            this.Cb_CapNhat.Name = "Cb_CapNhat";
            size = new Size(0x74, 0x11);
            this.Cb_CapNhat.Size = size;
            this.Cb_CapNhat.TabIndex = 0x2c;
            this.Cb_CapNhat.Text = "Cập nhật lại dữ liệu";
            this.Cb_CapNhat.UseVisualStyleBackColor = true;
            this.Label1.AutoSize = true;
            point = new Point(0x26, 0x1a);
            this.Label1.Location = point;
            this.Label1.Name = "Label1";
            size = new Size(0x26, 13);
            this.Label1.Size = size;
            this.Label1.TabIndex = 1;
            this.Label1.Text = "Đơn vị";
            this.CboDonVi.FormattingEnabled = true;
            point = new Point(0x75, 0x17);
            this.CboDonVi.Location = point;
            this.CboDonVi.Name = "CboDonVi";
            size = new Size(240, 0x15);
            this.CboDonVi.Size = size;
            this.CboDonVi.TabIndex = 0;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.background;
            size = new Size(0x18a, 0xa4);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.CmdCancel);
            this.Controls.Add(this.CmdOK);
            this.Controls.Add(this.GroupBox1);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_RptKetQuaHoatDongKinhDoanh";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Tag = "BC-0028             ";
            this.Text = "KET QUA HOAT DONG KINH DOANH";
            this.GroupBox1.ResumeLayout(false);
            this.GroupBox1.PerformLayout();
            this.ResumeLayout(false);
        }

        public void PrintReport()
        {
            this.Cursor = Cursors.WaitCursor;
            this.pdata = this.GetData();
            if (this.pdata != null)
            {
                string str;
                if ((LVYModule.sLeft(this.TxtTuNgay.Text, 5) == "01/01") & (LVYModule.sLeft(this.TxtDenNgay.Text, 5) == "31/12"))
                {
                    str = modGeneral.Tranlated("Năm", "") + " " + LVYModule.sRight(this.TxtTuNgay.Text, 4);
                }
                else
                {
                    str = modGeneral.Tranlated("Từ ng\x00e0y", "") + " :" + this.TxtTuNgay.Text + " " + modGeneral.Tranlated("đến ng\x00e0y", "") + ":" + this.TxtDenNgay.Text;
                }
                if (this.pdata.Rows.Count == 0)
                {
                    LVYModule.ShowWarning(modGeneral.Tranlated("Kh\x00f4ng c\x00f3 dữ liệu !", ""));
                }
                else
                {
                    Rpt_KetQuaHoatDongKinhDoanhCN hcn = new Rpt_KetQuaHoatDongKinhDoanhCN();
                    try
                    {
                        hcn.SetDataSource(this.pdata);
                        if (modGeneral.H_LANGUAGE == "VIET")
                        {
                            hcn.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEVIET, ""));
                        }
                        else
                        {
                            hcn.SetParameterValue(0, modGeneral.Tranlated(modGeneral.H_COMPANYNAMEANH, ""));
                        }
                        hcn.SetParameterValue(1, modGeneral.Tranlated("Địa chỉ", "") + ": " + modGeneral.H_ADDRESS);
                        hcn.SetParameterValue(2, modGeneral.Tranlated("M\x00e3 số thuế", "") + ": " + modGeneral.H_TAXCODE);
                        hcn.SetParameterValue(3, modGeneral.Tranlated("Điện thoại", "") + ": " + modGeneral.H_TELEPHONE);
                        hcn.SetParameterValue(4, modGeneral.Tranlated("Fax", "") + ": " + modGeneral.H_FAX);
                        hcn.SetParameterValue(5, modGeneral.Tranlated("B\x00c1O C\x00c1O KẾT QUẢ HOẠT ĐỘNG KINH DOANH", ""));
                        hcn.SetParameterValue(6, str);
                        hcn.SetParameterValue(7, modGeneral.Tranlated("Chỉ ti\x00eau", ""));
                        hcn.SetParameterValue(8, modGeneral.Tranlated("M\x00e3 số", ""));
                        hcn.SetParameterValue(9, modGeneral.Tranlated("Thuyết minh", ""));
                        hcn.SetParameterValue(10, modGeneral.Tranlated("Năm nay", ""));
                        hcn.SetParameterValue(11, modGeneral.Tranlated("Năm trước", ""));
                        hcn.SetParameterValue(12, modGeneral.Tranlated("Người lập biểu", ""));
                        hcn.SetParameterValue(13, modGeneral.Tranlated("Kế to\x00e1n trưởng", ""));
                        hcn.SetParameterValue(14, modGeneral.Tranlated("Gi\x00e1m đốc", ""));
                        hcn.SetParameterValue(15, modGeneral.Tranlated("(K\x00fd, họ t\x00ean, đ\x00f3ng dấu)", ""));
                        hcn.SetParameterValue(0x10, modGeneral.Tranlated("Ng\x00e0y ...... th\x00e1ng ...... năm ...............", ""));
                        if (modGeneral.H_PHIENBANQUYETDINH == "QD15")
                        {
                            hcn.SetParameterValue(0x11, "Mẫu số B02 - DN");
                            hcn.SetParameterValue(0x12, "(Ban h\x00e0nh theo QĐ số 15/2006/QĐ-BTC\nNg\x00e0y 20/03/2006 của Bộ trưởng Bộ T\x00e0i ch\x00ednh)");
                        }
                        else
                        {
                            hcn.SetParameterValue(0x11, "Mẫu số B02 - DNN");
                            hcn.SetParameterValue(0x12, "(Ban h\x00e0nh theo QĐ số 48/2006/QĐ-BTC\nNg\x00e0y 14/09/2006 của Bộ trưởng Bộ T\x00e0i ch\x00ednh)");
                        }
                        MyProject.Forms.Frm_ViewReport.ReportViewer.ReportSource = hcn;
                        MyProject.Forms.Frm_ViewReport.ReportViewer.DisplayGroupTree = false;
                        MyProject.Forms.Frm_ViewReport.ShowDialog();
                        this.Cursor = Cursors.Default;
                    }
                    catch (Exception exception1)
                    {
                        ProjectData.SetProjectError(exception1);
                        Exception exception = exception1;
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(exception.Message.ToString());
                        ProjectData.ClearProjectError();
                    }
                }
            }
        }

        private void TxtTuNgay_LostFocus(object sender, EventArgs e)
        {
            this.TxtDenNgay.Text = DateTime.DaysInMonth(Conversions.ToInteger(LVYModule.sRight(this.TxtTuNgay.Text, 4)), Conversions.ToInteger(LVYModule.sMid(this.TxtTuNgay.Text, 4, 2))).ToString() + "/" + LVYModule.sRight(this.TxtTuNgay.Text, 7);
        }

        internal virtual CheckBox Cb_CapNhat
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Cb_CapNhat;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Cb_CapNhat = value;
            }
        }

        internal virtual ComboBox CboDonVi
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CboDonVi;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._CboDonVi = value;
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual GroupBox GroupBox1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._GroupBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._GroupBox1 = value;
            }
        }

        internal virtual Label Label1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label13
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label13;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label13 = value;
            }
        }

        internal virtual Label Label2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual DateTimePicker TxtDenNgay
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtDenNgay;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtDenNgay = value;
            }
        }

        internal virtual DateTimePicker TxtTuNgay
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtTuNgay;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtTuNgay_LostFocus);
                if (this._TxtTuNgay != null)
                {
                    this._TxtTuNgay.LostFocus -= handler;
                }
                this._TxtTuNgay = value;
                if (this._TxtTuNgay != null)
                {
                    this._TxtTuNgay.LostFocus += handler;
                }
            }
        }
    }
}

